package com.vrv.app.cyberspace.modules.sys.controller;


import com.vrv.app.cyberspace.common.utils.JSONResult;
import com.vrv.app.cyberspace.common.validator.Assert;
import com.vrv.app.cyberspace.modules.sys.service.IEventApprovalTableService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sm
 * @since 2017-12-25
 */
@Api(description="事件审批流程")
@RestController
@RequestMapping("/sys/eventApproval")
public class EventApprovalTableController {
    @Autowired
    private IEventApprovalTableService eventApprovalTableService;

    @PutMapping()
    public JSONResult updateEventApproval(Integer baseID, String advice, String approvalUserID, Integer type){
        Assert.isNull(baseID,"baseID不能为空");
        Assert.isNull(type,"type不能为空");
        if (type==1){
            return eventApprovalTableService.addEventApproval(baseID,advice,approvalUserID);
        }else if (type==2){
            return eventApprovalTableService.endEventApproval(baseID,advice);
        }else if (type==3){
            return eventApprovalTableService.backEventApproval(baseID,advice);
        }else if (type==4){
            return eventApprovalTableService.archiveEventApproval(baseID,advice);
        }
        return JSONResult.renderError();
    }
}

